package com.rover022.flixelgame.vo
{
	import com.rover022.flixelgame.ui.BaseUI;
	
	  

	/**
	 * 玩家信息
	 * 务必保持new出来的时候各个数据都有初始值;
	 * @author flashpig
	 *
	 */
	public class UserVo
	{
		private var uiArray:Array = [];
		public var gold:uint = 0;
		public var gem:uint = 0;
		public var power:uint = 0;
		public var lv:uint = 0;
		public var exp:uint = 0;
		public var headImage:String = ""
		public var playName:String = ""
		public var heros:Array = []; //英雄角色数组  HeroVo
		public var items:Array = []; //角色道具数组 ItemVo
		public var pvpTeam:Array=[]; //角色pk队伍
		public var pveTeam:Array=[]; //角色副本队伍
		public var groceryGoods:Array=[]; //角色杂货铺商品

		public function UserVo()
		{
			uiArray = [];
		}

		public function setGold(src:uint):void
		{
			gold = src;
			sendMessage();
		}

		public function setgem(src:uint):void
		{
			gem = src;
			sendMessage();
		}

		public function setPower(src:uint):void
		{
			power = src;
			sendMessage();
		}

		public function setLv(src:uint):void
		{
			lv = src;
			sendMessage();
		}

		public function setExp(src:uint):void
		{
			exp = src;
			sendMessage();
		}

		public function register(_ui:BaseUI):void
		{
			uiArray.push(_ui);
		}

		public function unregister(_ui:BaseUI):void
		{
		 	var num:int = uiArray.indexOf(_ui);
			if(num!=-1){
				uiArray.splice(num,1);
			}
		 
		}

		/**
		 * 自动发送绑定的UI更新信息
		 *
		 */
		public function sendMessage():void
		{
			for (var i:int = 0; i < uiArray.length; i++)
			{
				uiArray[i].update();
			}
		}
	}
}
